package com.ym521.sadcrash

import android.app.Application
import com.ym521.sadcrash.callback.CrashCallback
import com.ym521.sadcrash.core.ActivityManager
import com.ym521.sadcrash.core.CrashManager

/**
 *@author Ym
 *E-mail: 2435970206@qq.com
 *createTime:2023/6/11
 *explain:
 * SadCrash 对外公开的函数
 */
object SadCrash {
    private lateinit var am: ActivityManager
    private lateinit var cm:CrashManager

    @JvmStatic
    fun install(application: Application) {
        am = ActivityManager()
        application.registerActivityLifecycleCallbacks(am)
        cm = CrashManager()
        cm.register(am)
    }

    @JvmStatic
    fun install(application: Application,callback: CrashCallback) {
        am = ActivityManager()
        application.registerActivityLifecycleCallbacks(am)
        cm = CrashManager()
        cm.register(am)
        cm.callBack = callback
    }
    @JvmStatic
    fun setCrashListener(callback: CrashCallback){
        cm.callBack = callback
    }

}